<script>
$(document).ready(function() {
    //prepare the dialog
	
    $( "#success" ).dialog({
		title: "Thông báo",
        autoOpen: false,
        show: {
            effect: "blind",
            duration: 500
            },
        hide: {
            effect: "blind",
            duration: 500
            },
        modal: true,
		buttons: {
			 "Ok": function() {
				location.reload();
				 $('#success').dialog('close');
			}
		 }
        });

	$(".close_addservice").click(function(event) {
				$('#dialogModal').dialog('close');
			});
    });
	
	function checkPass()
	{
		//Store the password field objects into variables ...
		var pass1 = document.getElementById('pass1');
		var pass2 = document.getElementById('pass2');
		//Store the Confimation Message Object ...
		var message = document.getElementById('confirmMessage');
		//Set the colors we will be using ...
		var goodColor = "#66cc66";
		var badColor = "#ff6666";
		//Compare the values in the password field
		//and the confirmation field
		if(pass1.value == pass2.value){
			//The passwords match.
			//Set the color to the good color and inform
			//the user that they have entered the correct password
			pass2.style.backgroundColor = goodColor;
			message.style.color = goodColor;
			message.innerHTML = "Mật khẩu khớp!"
		}else{
			//The passwords do not match.
			//Set the color to the bad color and
			//notify the user.
			pass2.style.backgroundColor = badColor;
			message.style.color = badColor;
			message.innerHTML = "Mật khẩu chưa khớp!"
		}
	}  
</script>

	<?php echo $this->Form->create('User',array('controller'=>'users','action'=>'edit')); ?>
		<div class="row">
			<label>Tên nhân viên</label>
			<?php echo $this->Form->input('name',array('label'=>false, 'style'=>'max-width:256px;','div'=>false));?>
		</div>
		<div class="row">
			<label>Tên đăng nhập</label>
			<?php echo $this->Form->input('username',array('label'=>false, 'style'=>'max-width:256px;','div'=>false,'disabled'=>'disabled'));?>
			<?php //echo $this->Form->hidden('id',array('value'=>$this->data['User']['id']));?>
		</div>		
		<div class="row">
			<label>Email</label>
			<?php echo $this->Form->input('email',array('label'=>false, 'style'=>'max-width:256px;','div'=>false));?>
		</div>
		<div class="row">
			<label>Ngày sinh</label>
			<?php echo $this->Form->input('bird',array('label'=>false, 'style'=>'max-width:256px;','div'=>false));?>
		</div>
		<div class="row">
			<label>Số Chứng minh thư</label>
			<?php echo $this->Form->input('cmt',array('label'=>false, 'style'=>'max-width:256px;','div'=>false));?>
		</div>
		<div class="row">
			<label>Giới tính</label>
			<?php $options = array(1=>"Nam",2=>"Nữ");?>
			<?php echo $this->Form->input('sex',array('options'=>$options,'label'=>false, 'style'=>'max-width:256px;','div'=>false));?>
		</div>
		<div class="row">
			<label>Địa chỉ thường trú</label>
			<?php echo $this->Form->input('thuongtru',array('label'=>false, 'style'=>'max-width:256px;','div'=>false));?>
		</div>
		<div class="row">
			<label>Địa chỉ tạm trú</label>
			<?php echo $this->Form->input('tamtru',array('label'=>false, 'style'=>'max-width:256px;','div'=>false));?>
		</div>
		<div class="row">
			<label>Số điện thoại</label>
			<?php echo $this->Form->input('phone',array('label'=>false, 'style'=>'max-width:256px;','div'=>false));?>
		</div>
		<div class="row">
			<label>Ngày bắt đầu làm việc</label>
			<?php echo $this->Form->input('start',array('label'=>false, 'style'=>'max-width:256px;','div'=>false));?>
		</div>
		<div class="row">
			<label>Số ngày làm việc/tháng</label>
			<?php echo $this->Form->input('datework',array('label'=>false, 'style'=>'max-width:256px;','div'=>false,'type'=>'text'));?>
		</div>
		<div class="row">
			<label>Mức lương</label>
			<?php  echo $this->Form->input('salary',array('label'=>false,'div'=>false,'id'=>'salary','type'=>'text'));?>
			<script type="text/javascript">$("#salary").maskMoney();</script>
		</div>
		<div class="row">
			<label>Nhóm người dùng</label>
			<?php //debug($cate);?>
			<?php echo $this->Form->input('groups_id',array('label'=>false, 'style'=>'max-width:256px;','div'=>false));?>
		</div>
		<div class="row">
			<label>Thông tin thêm</label>
			<?php  echo $this->Form->input('note',array('label'=>false,'div'=>false));?>
		</div>
		<div class="btn-dialog">
			
			<?php 
			echo $this->Js->submit('Ok', array(  //create 'ajax' save button
				'update' => '#contentWrap','div'=>false  //id of DOM element to update with selector
				));
			if (false != $saved){ //will only be true if saved OK in controller from ajax save above
				echo "<script>
					$('#success').dialog('open');  //close containing dialog 
				</script>";
				}
			echo $this->Form->end();
			echo $this->Js->writeBuffer();
			?>

			<input type="button" value="Cancel" class="close_addservice">
		</div>

<div id="success" title="Thông báo">
<p align="center">Đã sửa thông tin thành công</p>
</div>
